package p3.genetic;

import p3.game.SetOfGames;
import generic.genetic.chromosome.Chromosome;
import generic.genetic.chromosome.TreeChromosome;

public class InvadersChromosome extends TreeChromosome{

	protected SetOfGames sog;
	//protected float fitness;
	
	public InvadersChromosome(SetOfGames sog, int max_depth){
		super(max_depth);
		this.sog = sog;
		//fitness = Float.MAX_VALUE;
	}
	
	public InvadersChromosome(InvadersChromosome ic){
		super(ic);
		sog = ic.sog;
		//fitness = ic.getFitness();
	}
	
		@Override
	public float evaluate() {
		
		float fitness = sog.getCopy().execute(tree);
		//bloating penalty per level
		int depth = tree.getMaxDepth();
		depth -= max_depth;
		if (depth > 0) fitness += depth*100;
		return fitness; 
	}
	
	public Chromosome getCopy(){
		return new InvadersChromosome(this);
	}

	//private float getFitness() { return fitness; }
}
